package people.paper.tv.speech;

import android.content.Context;

import people.paper.tv.speech.impl.baidu.BaiduSpeechCore;


public class SpeechManager implements SpeechCore {
    private static SpeechManager speechManager;

    public synchronized static final void create(Context context) {
        if (speechManager == null)
            speechManager = new SpeechManager(context);
    }

    public synchronized static final void destroy() {
        if (speechManager != null) {
            speechManager.release();
            speechManager = null;
        }
    }

    public static final SpeechManager getSpeechManager() {
        return speechManager;
    }

    private SpeechCore core;

    private SpeechManager(Context context) {
        core = new BaiduSpeechCore(context);
    }

    @Override
    public void setSpeechCoreListener(SpeechCoreListener listener) {
        core.setSpeechCoreListener(listener);
    }

    @Override
    public int play(String text) {
        return core.play(text);
    }

    @Override
    public int getPlayingID() {
        return core.getPlayingID();
    }

    @Override
    public boolean isPlaying() {
        return core.isPlaying();
    }

    @Override
    public void pause(int id) {
        core.pause(id);
    }

    @Override
    public boolean isPaused() {
        return core.isPaused();
    }

    @Override
    public void resume(int id) {
        core.resume(id);
    }

    @Override
    public boolean stop(int id) {
        return core.stop(id);
    }

    @Override
    public void release() {
        core.release();
    }
}
